package com.gitee.wsl.struct.grammar.parser.context.ext

import com.gitee.wsl.struct.grammar.parser.ParsingScope

inline fun ParsingScope.dropWhile(block: (Char) -> Boolean) {
    while (true) {
        if (position == inputString.length) return
        val char = inputString[position]
        if (!block(char)) break
        position++
    }
}

fun ParsingScope.dropFirst() {
    drop(n = 1)
}

fun ParsingScope.drop(n: Int) {
    position = (position + n).coerceAtMost(inputString.length)
}
